<?php
    $Mode = $_POST["mode"];
    $Deta_emp_id = $_POST["emp_id_post"];
    $Deta_emp_birthdate = $_POST["emp_birthdate"];

    $conn_string = "host=localhost port=5432 dbname=sveng user=postgres password=P@ssw0rd "or die ("Could not connect to server\n"); 
    $con = pg_connect($conn_string);
    if ($Mode == "CheckID") {
        $query = "SELECT * FROM mwa_emp WHERE emp_id = '$Deta_emp_id' "; 
        $rs = pg_query($con, $query) or die("Cannot execute query: $query\n"); 
        $row = pg_fetch_row($rs);
        if ($row > 1) {
            echo 1;
        }
        else{
            echo 0;
        }
    }
    if ($Mode == "CheckBirtdate") {
        $query = "SELECT * FROM mwa_emp WHERE emp_id = '$Deta_emp_id' and emp_birthdate = '$Deta_emp_birthdate' "; 
        $rs = pg_query($con, $query) or die("Cannot execute query: $query\n"); 
        $row = pg_fetch_row($rs);
        if ($row > 1) {
            echo 1;
        }
        else{
            echo 0;
        }   
    }
    pg_close($con); 
?>
